<?php
/**
 * 修改用户呢称和头像
 */
require_once dirname(__DIR__)."/login_filter.php";
use app\cls\tom\Response;
use app\cls\tom\SysResource;
use app\cls\tom\Tools;
use app\model\HomePage;
use app\model\Users;
//接收参数
$nick_pic=$_REQUEST['nick_pic'];//用户头像
if(empty($nick_pic)){
    Response::output(-1,"缺少参数");
}
//用户uuid
$PATH="test";
$uuid=$Auth['uuid'];
$suffix=rand(1,5);
if($PATH=="test"){
    $user_key=REDIS_PREFIX."test_user_info_replace_".$uuid;
    $duilie_key = REDIS_PREFIX."test_user_info_replace".$suffix;//这是入统计队列的key
}else if($PATH=="no_test"){
    $user_key=REDIS_PREFIX."user_info_replace_".$uuid;
    $duilie_key = REDIS_PREFIX."user_info_replace".$suffix;//这是入统计队列的key
}
//实例化redis
$redis = SysResource::getRedis();
//实例化数据库
$db = SysResource::getDB(false);
$Users = new Users($db);

//先判断redis里是否有这个key
$redis_key=$redis->get($user_key);
if(empty($redis_key)){
    //先把数据加入队列
    $data['nick_pic']=$nick_pic;
    $data['uuid']=$uuid;
    $redis->lPush($duilie_key,json_encode($data));
    //在设置个人对列的过期时间
//    $data['time']=date("Y-m-d H:i:s",time());
    $redis->setex($user_key,3600,$data);
    Response::output(0,"添加成功1",$suffix,$duilie_key);
}else{
    Response::output(0,"添加成功2");
}





//按本周时间查询数据，拼接的时间
function times(){
    $today=strtotime(date("Y-m-d"),time());
    $time['end']=date("Y-m-d H:i:s",$today+86400);
    $time['start']=date("Y-m-d H:i:s",$today-6*86400);
    return $time;
}

